package com.renge.handler;

import com.renge.commonutils.R;
import com.renge.exception.GuliException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 统一异常处理类
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public @ResponseBody R error(Exception e){
        e.printStackTrace();
        return R.error().code(250);
    }
    @ExceptionHandler(GuliException.class)
    public @ResponseBody R error(GuliException e){
        e.printStackTrace();
        return R.error().message(e.getMsg()).code(e.getCode());
    }
}
